home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-30 | 2.3 KB | 47 lines | [TEXT/PJMM] |
- unit TextFileIntf;
- {CTextFile v1.1 © 1992 by William Studenmund. For distribution info,}
- {please see attached About file. This class impliments a TEXT file à la}
- {THINK Pascal. Only String reading & writing is supported.}
- interface
- uses
- TCL;
- const
- TextBufferSize = 511;
- TextEOLChar = char(13);
- TextSpaceChar = ' ';
- type
- TextBufferT = packed array[0..TextBufferSize] of char;
- CTextFile = object(CDataFile)
- theBuffer: TextBufferT;
- BufferLen, BufferPos: integer;
- OpenForInput, BufferHasData, MoreInFile, HaveAccessed, LastWroteCR, ForceEOL, LongLine: boolean;
- theLength, LengthLeft: longint;
- procedure ITextFile; {Zeroes a bunch of things. The real fun is in the Open procedure}
- function EOF: boolean;
- function EOL: boolean;
- function isLongLine: boolean; {True if the Read(Ln) routine was kept from finishing the line. See specific routine.}
- function getLengthLeft: longint; {How many characters are left in the file THAT HAVEN'T BEEN READ INTO RAM.}
- procedure Seek (thePlace: longint); {Pascal way of setting "the Mark." Provided since it's in the Language def.}
- function Filepos: longint; {Pascal way of getting "the Mark"'s position.}
-
- function Peek: char;
- procedure Read (var theString: string; HowMuch: integer);
- procedure ReadLn (var theString: string);
- procedure Write (var theString: string); {VAR only for speed}
- procedure WriteLn (var theString: string); {VAR only for speed}
-
- procedure Open (permission: SignedByte);
- override; {Note: TextFile only supports exclusive Read or exclusive Write permission. As it is}
- {designed to simulate TEXT files, ie one-way streams of information. I don't want to}
- {go through and add the complexity of supporting simultaneous read/write ability. If}
- {you need that, you don't want this file type. NB: if the file doesn't exist when opening for writing,}
- {this routine will create it as type 'TEXT' & signature gSignature. If you don't want that,}
- {create the file before opening}
- procedure Reset; {Pascal way of opening file for read-only seuential access}
- procedure Rewrite; {Pascal way of opening an empty file for write-only access}
- procedure OpenForAppending; {Custom method of opening a file to append to it.}
-
- procedure ReadBuffer; {For internal use only}
- end;
- implementation
- end.